﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="service.aspx.cs" Inherits="ZF.WS.Person.expert.service" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <link href="/css/common.css" rel="stylesheet" type="text/css" /><link href="/css/default.css" rel="stylesheet" type="text/css" /><link href="../css/default.css" rel="stylesheet" type="text/css" />
    <script src="/js/jQuery.js" type="text/javascript"></script>

    <script src="js/jquery-1.4.2.js" type="text/javascript"></script>
    <script src="/js/calendar.js" type="text/javascript"></script>
    <script src="/js/index.js" type="text/javascript"></script>

    <script src="/js/jqPlugins/jquery.json-2.2.min.js" type="text/javascript"></script>
    
    


    <style>
        *
        {
            margin: 0px;
            padding: 0px;
            font-size: 12px;
            list-style: none;
            font-family: 宋体,arial,verdana,sans-serif,fantasy,tahoma;
        }
    </style>

 
    <script>
        $(function() {
            SlideInit();
        });
        function SlideInit() {
            $(".board").each(function() {
                var board = this;
                $(board).find("dt a.slide").click(function() {

                    $(board).find("dd.slide").hide();

                    $(board).find("a.slide").removeClass("active");
                    $("." + $(this).attr("bind")).show();
                    $(this).addClass("active");
                });
            });
        }
    
    </script>
    
</head>
<body>
    <form id="form1" runat="server">
    
 <style>
.board { border: 1px solid #BCDDF4; width: 100%; }
.board dl dt { background: #BCDDF4 url(/image/title_bg1.gif) repeat-x; height: 25px; line-height: 25px; vertical-align: middle; font-weight: bold; color: #1D72AF; text-align: left; margin-bottom: 5px; }
.board dl dt a { display: block; min-width: 100px; width: 100px; float: left; border-right: 1px solid #BCDDF4; text-align: center; border-bottom: 0px solid #BCDDF4; color: #1D73B0; }
.board dl dt a:hover1 { background: url(/image/title_bg2.gif); border-bottom: 0px solid #fff; }
.board dl dt a.active { background: url(/image/title_bg2.gif); margin-bottom: 21px; border-bottom: 0px solid #fff; }
.board dl dt a.more { color: #F00; border-right: none; float: right; width: 50px; padding-right: 10px; }
.board dl dt a.more:hover { background: none; text-decoration: underline; border-bottom: 0px solid #BCDDF4; }
.board dl dt span { padding: 0px 10px; float: left; }
.board dl dt p { padding: 0px 10px; float: left; border-right: 1px solid #BCDDF4; }
.board dl dd { width: 100%; }
.board .page table { text-align: center; }
.board .page a { display: block; text-align: center; line-height: 20px; height: 20px; width: 60px; float: left; border: 1px solid #eee; margin: 5px 10px; padding: 5px; font-weight: bold; }
.board .page a:hover { background: #5372A9; color: #fff; }
.board1 dl dt a { color: #666; font-weight: normal; }
      body{width:97%;}
.divIFrame{ width:100%; height:480px;  }
 .divIFrame dl dt a{ display:block; float:left;  width:150px; cursor:pointer; line-height:24px;  height:24px; *padding-top:6px;}
 .divIFrame dt a img{ padding-top:1px; margin-left:5px;margin-right:5px; }
 .divIFrame dt a.active{  }
 .divIFrame dl dt a.rf1{ background: #BCDDF4;}
 .divIFrame dl dt a.rf2{  color:#FF0000;}
 .divIFrame dl dd{ display:none; padding:2px;}
 .divIFrame dl dd.active{ display:block;}
 </style>
 
<div id="msg">


</div>
 
<script>
    var wstatus = 2;
    $(function() {
        var rows0 = "0,*";
        var rows1 = "50%,*";
        var rows2 = "*,33";
        $(".amax").click(function() {
            parent.document.getElementById("mframer").rows = rows0;
            return false;
        });
        $(".anor").click(function() {
            parent.document.getElementById("mframer").rows = rows1;
            return false;
        });

        $(".amin").click(function() {
            parent.document.getElementById("mframer").rows = rows2;
            return false;
        });

    })

 
</script>
<div class="board divIFrame"  >
    <dl>
        <dt>
            <table class="w100_ table000_">
                <tr>
                    <td>
                        <div style="width: 100%;">
                         <span style="color: #339900;">在线咨询服务已开启</span>
                        </div>
                       
                    </td>
                    <td style="width: 170px; cursor:pointer; ">
                       <span class="amax">最大化</span>
                    <span class="anor">平分</span> 
                       <span class="amin">最小化</span>
                    </td>
                </tr>
            </table>
        
        
       </dt>
       
    </dl>
    
     <div class="atemplate dn_">
       <a bind="{0}" name='{1}'>{1}<img src="/images/tab-close.gif" title="关闭" /></a>
    </div>
    <div class="ddtemplate dn_">
       <dd bind='{0}'><iframe src="_s.aspx?rk={0}&id=<%=this.CurrentUser.MemberId %>"  frameborder="no" border="0" marginwidth="0"
        scrolling="no" marginheight="0" allowtransparency="yes"  style=" border:0px; width:100%; height:488px;"></iframe></dd>
    </div>
</div>




<script>
var memberId=<%=this.CurrentUser.MemberId %></script>
<script>


    $(function() {
        _keep();
        _getCall();
        _autoReflashbg();
        _autoReflashTxt();
    });
     var divIFrame = null;
     function _setTitleEvent(key) {
         if (divIFrame == null)
             divIFrame = $(".divIFrame");
         var alink = divIFrame.find(String.format("dt a[@bind='{0}']", key))[0];
         alink.key = key;
         $(alink).click(function() {
             divIFrame.find("dt a").removeClass("active");
             $(this).addClass("active");

             divIFrame.find("dd").removeClass("active");
             divIFrame.find(String.format("dd[@bind='{0}']", $(this).attr("bind"))).addClass("active");
         });

         $(alink).find("img").click(function() {
             var cr = confirm(String.format("是否关闭与{0}的对话", $(this.parentNode).attr("name")));
             if (cr) {
                 var active = $(this.parentNode).hasClass("active");
                 var key = $(this.parentNode).attr("bind");
                 $.ajax({
                     type: "POST",
                     data: $.toJSON({ memberId: memberId, roomKey: key }),
                     contentType: "application/json",
                     url: "/WSChat.asmx/Out",
                     cache: false,
                     async: false,
                     success: function(msg) {
                         var msg = $.evalJSON(msg).d;
                     }
                 });
                 divIFrame.find(String.format("dd[@bind='{0}']", $(this.parentNode).attr("bind"))).remove();
                 $(this.parentNode).remove();
                 if (active) {
                     if (divIFrame.find("dt a").length > 0)
                         divIFrame.find("dt a")[0].click();
                 }
             }
             return false;
         });
         if (divIFrame.find("dt a.active").length == 0 &&
            divIFrame.find("dt a").length > 0) {
             divIFrame.find("dt a")[0].click()
             if(wstatus==2)
                 setBgReflash(alink)
         } else {
            if(!_getCallFirst)
                setBgReflash(alink);
         }
         
     }
    var refbgArr = [];
    function setBgReflash(obj) {
        obj.bgcount = 20;
        refbgArr.push(obj)
    }
    function _autoReflashbg() {

        $(refbgArr).each(function() {
            if (this.bgcount > 0) {
                if (!$(this).hasClass("active")) {
                    if ($(this).hasClass("rf1")) {
                        $(this).removeClass("rf1");
                    }
                    else
                        $(this).addClass("rf1");
                    this.bgcount--;
                } else {
                    $(this).removeClass("rf1");
                    this.bgcount = 0;
                }

            }
        });
        setTimeout("_autoReflashbg()", 500);
    }
    var reftxtArr = [];
    function setTxtReflash(obj) {
        obj.txtcount = 10;
        reftxtArr.push(obj)
    }
    function _autoReflashTxt() {

        $(reftxtArr).each(function() {
            if (this.txtcount > 0) {
            
                if (!$(this).hasClass("active")) {
                    if ($(this).hasClass("rf2")) {
                        $(this).removeClass("rf2");
                    }
                    else
                        $(this).addClass("rf2");
                    this.txtcount--;
                } else {

                     $(this).removeClass("rf2");
                    this.txtcount = 0;
                }

            }
        });
        setTimeout("_autoReflashTxt()", 500);
    }

    function _refTxt(key) {
        var txt = null;
        $(reftxtArr).each(function() {
            if (this.key == key) {
                txt = this;
                return false;
            }
        });
        if (txt == null) {
            txt = divIFrame.find(String.format("dt a[@bind='{0}']", key))[0]
            setTxtReflash(txt);
        }else
            txt.txtcount = 10;
        
  
    }
    
    var i_getCall = 1
    var i_keep = 5;
    var _getCallFirst = true;
    function _getCall() {
        i_getCall--
        if (i_getCall == 0) {
            i_getCall = 5;
            setTimeout("_getCall()", 1000);
            $.ajax({
                type: "POST",
                data: $.toJSON({ memberId: memberId, getAll: _getCallFirst }),
                contentType: "application/json",
                url: "/WSChat.asmx/RecCall",
                cache: false,
                async: false,
                success: function(msg) {
                    var msg = $.evalJSON(msg).d;
                    if (msg.length > 0) {
                        var ddtemplate = $(".divIFrame .ddtemplate").html();
                        var atemplate = $(".divIFrame .atemplate").html();
                        $(msg).each(function() {
                            $(".divIFrame dl").append(String.format(ddtemplate, this.RoomKey));
                            $(".divIFrame dt div").append(String.format(atemplate, this.RoomKey, this.FromMember));
                            _setTitleEvent(this.RoomKey);
                           
                        });
                    }
                }
            });
            _getCallFirst = false;
        } else
            setTimeout("_getCall()", 1000);
    }
    
    
    
    function _keep() {
        i_keep--
        if (i_keep == 0) {
            i_keep = 5;
            setTimeout("_keep()", 1000);
            $.ajax({
                type: "POST",
                data: String.format("{memberId:{0}}", memberId),
                contentType: "application/json",
                url: "/WSChat.asmx/Keep",
                cache: false,
                async: false,
                success: function(msg) {
                   
                }
            });
        }else
            setTimeout("_keep()", 1000);

    }
</script>

    </form>
</body>
</html>
